#pragma once
#include "GameState.h"
#include "MenuState.h"
#include <cmath>

class IntroState : public GameState
{
public:

	void Init(GameEngine* game)
	{
		printf("=======Introstate\n");

		if (!_Font.LoadFromFile("./data//quantflt.ttf"))
		{
			_Font.GetDefaultFont();
		}

		_Text.SetCharacterSize(60);
		_Text.SetFont(_Font);
		_Text.SetString("BitShift");
		_Text.SetColor(sf::Color(0xFF,0x99,0));
		_Text.SetStyle(sf::Text::Underlined);

		_About.SetCharacterSize(10);
		_About.SetFont(_Font);
		_About.SetString("DEElekgolo");
		_About.SetColor(sf::Color(0xFF,0x99,0));

		_BackGround = sf::Shape::Rectangle(0,0,300,100,sf::Color(33,33,33));
		_Time.Reset();
	}



	void Cleanup()
	{
		printf("=======Introstate End\n");
	}

	void Pause()
	{

	}
	void Resume()
	{

	}

	void HandleEvents(GameEngine* game)
	{
		sf::Event event;
		game->_Window.PollEvent(event);
		if (event.Type == sf::Event::KeyPressed)
		{
			game->ChangeState(MenuState::Instance());
		}
		if (event.Type == sf::Event::Resized)
		{
			game->_Width = event.Size.Width;
			game->_Height = event.Size.Height;
			game->_Window.SetView(sf::View(sf::FloatRect(0,0,(float)event.Size.Width,(float)event.Size.Height)));
		}
		if (_Time.GetElapsedTime() > 2500)
		{
			game->ChangeState(MenuState::Instance());
		}
	}

	void Update(GameEngine* game)
	{
		_BackGround.SetPosition((game->_Width/(float)2)-150,(game->_Height/(float)2)-50);
		_Text.SetPosition((game->_Width/(float)2)-135,(game->_Height/(float)2)-30);
		_About.SetPosition((game->_Width/(float)2)+60,(game->_Height/(float)2)+40);
	}

	void Draw(GameEngine* game)
	{
		game->_Window.Clear(sf::Color(28,28,28));


		game->_Window.Draw(_BackGround);
		game->_Window.Draw(_Text);
		game->_Window.Draw(_About);


		game->_Window.Display();
	}

	static IntroState* Instance()
	{
		return &iIntrostate;
	}
protected:
	IntroState(){};
private:
	static IntroState iIntrostate;

	sf::Font _Font;

	sf::Text _Text;

	sf::Text _About;

	sf::Shape _BackGround;


	sf::Clock _Time;
};

IntroState IntroState::iIntrostate;